package Week3.num.week3Test1.opp02;

public class HourlyEmployee extends ColaEmployee {
    private double hourSal;
    private int hour;

    public HourlyEmployee() {
    }

    public HourlyEmployee(String name, int month, double hourSal, int hour) {
        super(name, month);
        this.hourSal = hourSal;
        this.hour = hour;
    }

    public double getHourSal() {
        return hourSal;
    }

    public void setHourSal(double hourSal) {
        this.hourSal = hourSal;
    }

    public int getHour() {
        return hour;
    }

    public void setHour(int hour) {
        this.hour = hour;
    }


    @Override
    public double getSalary(int month) {

        //每月工作小时数标记
        int flag = 160;
        //超出部分工资倍数
        double temp = 1.5;
        //每月工资
        double sal = 0;
        //判断当月工作时间是否超出flag
        if (this.getHour() < flag) {
            sal = this.getHourSal() * this.getHour();
        } else {
            sal = this.getHourSal() * flag + this.getHourSal() * temp * (this.getHour() - flag);
        }

        if (month == this.getMonth()) {
            return (sal+100);
        }
        return sal;
    }
}
